﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using diploma.core.data.objects;
using diploma.core.data;
using diploma;

namespace diploma.test.GUI
{
    public partial class ChooseProperties : Form
    {
        List<Property> curProperties;
        public ChooseProperties(List<Property> _properties, DataList<diploma.core.data.IDataObject> _other)
        {
            InitializeComponent();
            listBox1.Items.AddRange(_properties.ToArray());
            List<Property> other = new List<Property>();
            foreach (Property p in _other)
            {
                if (!_properties.Contains(p))
                {
                    other.Add(p);
                }
            }
            listBox2.Items.AddRange(other.ToArray());
        }

        private void ChooseProperties_Load(object sender, EventArgs e)
        {

        }

        public List<Property> CurrentProperties
        {
            get
            {
                return curProperties;
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            curProperties = new List<Property>();
            foreach (object o in listBox1.Items)
            {
                curProperties.Add(o as Property);
            }
            Close();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            listBox2.Items.Add(listBox1.SelectedItems[0]);
            listBox1.Items.Remove(listBox1.Items[listBox1.SelectedIndex]);
        }

        private void button2_Click(object sender, EventArgs e)
        {

            listBox1.Items.Add(listBox2.SelectedItems[0]);
            listBox2.Items.Remove(listBox2.Items[listBox2.SelectedIndex]);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            foreach (object o in listBox1.Items)
            {
                listBox2.Items.Add(o);
            }
            listBox1.Items.Clear();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            foreach (object o in listBox2.Items)
            {
                listBox1.Items.Add(o);
            }
            listBox2.Items.Clear();
        }


    }
}
